/*************************************************************************
 * File Name:    4751.cc
 * Author:       zero91
 * Mail:         jianzhang9102@gmail.com
 * Created Time: Mon 23 Sep 2013 10:47:21 PM CST
 * 
 * Description:  http://acm.hdu.edu.cn/showproblem.php?pid=4751
 ************************************************************************/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>

using namespace std;

#define MAXN 110

int n;
bool matrix[MAXN][MAXN];
int group[MAXN];

bool
bfs(int v, int n)
{
    queue<int> q;
    int u;

    q.push(v);
    while (!q.empty()) {
        u = q.front();
        q.pop();

        for (int i = 1; i <= n; ++i) {
            if (i == u || (matrix[i][u] && matrix[u][i])) continue;

            if (group[i] == -1) {
                group[i] = group[u] ^ 1;
                q.push(i);
            } else if (group[i] == group[u]) {
                return false;
            }
        }
    }
    return true;
}

int
main(int argc, char *argv[])
{
#ifndef ONLINE_JUDGE
    freopen("input", "r", stdin);
#endif
    int t, i;

    while (scanf("%d", &n) != EOF) {
        memset(matrix, false, sizeof(matrix));
        for (i = 1; i <= n; ++i) {
            while (scanf("%d", &t) != EOF && t) {
                matrix[i][t] = true;
            }
        }
        memset(group, -1, sizeof(group));
        for (i = 1; i <= n; ++i) {
            if (group[i] == -1) {
                group[i] = 0;
                if (!bfs(i, n)) break;
            }
        }

        if (i <= n) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}
